//
//  UIView+DrawTools.m
//  MovingLoaniOS
//
//  Created by Rain on 2018/8/13.
//  Copyright © 2018 - 2019 GWMFC. All rights reserved.
//

#import "UIView+DrawTools.h"

@implementation UIView (DrawTools)

- (void)rg_addBorderWithWidth:(CGFloat)width
                 cornerRadius:(CGFloat)cornerRadius
                        color:(UIColor *)color
{
    self.layer.masksToBounds = YES;
    self.layer.borderWidth = width;
    self.layer.cornerRadius = cornerRadius;
    self.layer.borderColor = color.CGColor;
}


- (UIView *)rg_drawLineWithStartPoint:(CGPoint)startPoint
                               length:(CGFloat)length
                                width:(CGFloat)width
                                color:(UIColor *)color
                            direction:(RGLineDirection)direction
{
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = color;
    
    switch (direction) {
        case RGLineDirectionHorizontal:
            line.frame = CGRectMake(startPoint.x, startPoint.y, length, width);
            break;
            
        case RGLineDirectionVertical:
            line.frame = CGRectMake(startPoint.x, startPoint.y, width, length);
            break;
    }
    [self addSubview:line];
    return line;
}

@end


@implementation UIView (Interaction)

- (void)rg_interactionStatus:(BOOL)status {
    self.userInteractionEnabled = status;
    self.multipleTouchEnabled = status;
}

@end
